const CryptoJS  = require("crypto-js")

const keyStr = 'eSEdSfdED==WGDH'
// 加密
function encrypt(word) {
  const key = CryptoJS.enc.Utf8.parse(keyStr)
  const srcs = CryptoJS.enc.Utf8.parse(word)
  const encrypted = CryptoJS.AES.encrypt(srcs, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 })
  return encrypted.toString()
}

// 解密
function decrypt(word) {
  const key = CryptoJS.enc.Utf8.parse(keyStr)
  const decryptStr = CryptoJS.AES.decrypt(word, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 })
  return CryptoJS.enc.Utf8.stringify(decryptStr).toString()
}

exports.default = function () {
    encrypt;
    decrypt
}
